﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Xml.Serialization;

namespace WxServices.Models
{
    /// <summary>
    ///MsgId	消息id，64位整型
    ///MsgType	text|image|voice|video|location|link
    ///Content	文本消息内容
    ///CreateTime	消息创建时间 （整型）
    ///Description	消息描述
    ///Format	语音格式，如amr，speex等
    ///FromUserName	发送方帐号（一个OpenID）
    ///FromUserName	发送方微信号，若为普通用户，则是一个OpenID
    ///Label	地理位置信息
    ///Location_X	地理位置维度
    ///Location_Y	地理位置经度
    ///MediaId	视频消息媒体id，可以调用多媒体文件下载接口拉取数据。
    ///PicUrl	图片链接
    ///Scale	地图缩放大小
    ///ThumbMediaId	视频消息缩略图的媒体id，可以调用多媒体文件下载接口拉取数据。
    ///Title	消息标题
    ///ToUserName	开发者微信号
    ///ToUserName	接收方微信号
    ///Url	消息链接
    /// </summary>
    [XmlRoot("xml", Namespace = "")]
    public class WxMessageFull
    {
        public string Content { get; set; }
        public long CreateTime { get; set; }
        public string Description { get; set; }
        public string Format { get; set; }
        public string FromUserName { get; set; }
        public string Label { get; set; }
        public string Location_X { get; set; }
        public string Location_Y { get; set; }
        public string MediaId { get; set; }
        public long MsgId { get; set; }
        public string MsgType { get; set; }
        public string PicUrl { get; set; }
        public string Scale { get; set; }
        public string ThumbMediaId { get; set; }
        public string Title { get; set; }
        public string ToUserName { get; set; }
        public string Url { get; set; }
        [XmlElement("event")]
        public string Event { get; set; }//VIEW,CLICK,LOCATION,SCAN,subscribe,subscribe,unsubscribe
        //qrscene_二维码的参数值
        public string EventKey, Ticket, Latitude, Longitude, Precision;
    }


    [XmlInclude(typeof(WxResultFull))]
    [XmlInclude(typeof(WxResultText))]
    [XmlInclude(typeof(WxResultImage))]
    [XmlInclude(typeof(WxResultMusic))]
    [XmlInclude(typeof(WxResultNews))]
    [XmlInclude(typeof(WxResultVideo))]
    [XmlInclude(typeof(WxResultVoice))]
    [XmlInclude(typeof(WxResultBase))]
    [XmlRoot("xml", Namespace = "")]
    public class WxResultBase
    {
        public string
            ToUserName,
            FromUserName,
            CreateTime;
        public virtual string MsgType { get; set; }

    }
    [XmlRoot("xml", Namespace = "")]
    public class WxResultText : WxResultBase
    {
        public override string MsgType { get { return "text"; } set { } }
        public string Content;
    }


    [XmlRoot("xml", Namespace = "")]
    public class WxResultFull : WxResultBase
    {
        public string
            ArticleCount,
            Content,
            Description,
            HQMusicUrl,
            MediaId,
            MusicURL,
            ThumbMediaId,
            Title;
        public WxResultNewsArticleItem Articles;

    }

    [XmlRoot("xml", Namespace = "")]
    public class WxResultImage : WxResultBase
    {
        public override string MsgType { get { return "image"; }  }

        public string MediaId;
    }
    [XmlRoot("xml", Namespace = "")]
    public class WxResultVoice : WxResultBase
    {
        public override string MsgType { get { return "voice"; } }

        public string MediaId;
    }
    [XmlRoot("xml", Namespace = "")]
    public class WxResultVideo : WxResultBase
    {
        public override string MsgType { get { return "video"; } }
        public string MediaId, Title, Description;
    }
    [XmlRoot("xml", Namespace = "")]
    public class WxResultMusic : WxResultBase
    {
        public override string MsgType { get { return "music"; } }
        public string Title, Description, MusicURL, HQMusicUrl, ThumbMediaId;
    }
    [XmlRoot("xml", Namespace = "")]
    public class WxResultNews : WxResultBase
    {
        public override string MsgType { get { return "news"; } }
        public string Title, Description, ArticleCount;
        public WxResultNewsArticleItem[] Articles;
    }
    public class WxResultNewsArticleItem
    {
        public string Title, Description, Url, PicUrl;
    }
}
